<?php 
 namespace app\api\model;
 use think\Model;
 class User extends Model{
 	protected $pk ='u_id'; 	
 	
 	public function profile(){
 		return $this->hasOne(UserProfile::class,'u_id','u_id');
 	}	

 	public function authens(){
 		return $this->hasMany(UserAuthen::class,'u_id','u_id');
 	}

	public function admin(){
 		return $this->hasOne(Admin::class,'u_id','u_id');
 	}


 	public function getSexTextAttr($value,$data){
 		$sexs = [1=>__('man'),2=>__('women')];
 		return $sexs[$data['sex']];
 	}

 	public function roles(){
 		return $this->hasMany(RoleUser::class,'u_id','u_id');
 	}


 	/**
	 * 冻结获取器
	 * @param  [type] $value [字段值]
	 * @param  [type] $data  [行数据]
	 * @return [type]        [字符]
	 */
    public function getLockFlagTextAttr($value,$data){
    	$status = [1=>__('forbidden'),0=>__('normal')];
        return $status[$data['status']];
    }	
    


 	


 }